import { defineStore } from 'pinia'

export const useChatStore = defineStore('chat', {
  state: () => ({
    showType: 'box',
    boxShow: true,
    inputWay: 'keyboard',
    carState: {
      "车窗位置": 0,
      "空调温度": 26,
      "座椅位置": 0,
      "座椅靠背角度": 90,
      "音乐音量": 0,
      "音乐曲目": "宝宝",
      "天窗打开": 0,
      "童锁": 0,
      "香氛强度": 0,
      "计时器": 30,
      "计时器状态": "运行中",
      "氛围灯": 0,
      "氛围灯颜色": "白色",
      "氛围灯亮度": 50
    },
    zoomVal: 1,
  }),
  actions: {
    changeType(newType) {
      this.showType = newType
    },
    toggleBoxShow() {
      this.boxShow = !this.boxShow
    },
    changeInputWay() {
      this.inputWay = this.inputWay === 'keyboard' ? 'voice' : 'keyboard'
    },
    changeCarState(value) {
      // this.carState = value 
      this.carState = {
        "车窗位置": value.windowPosition - 0,
        "空调温度": value.airConditioningTemperature - 0,
        "座椅位置": value.seatPosition - 0,
        "座椅靠背角度": value.seatBackrestAngle - 0,
        "音乐音量": value.musicVolume - 0,
        "音乐曲目": value.musicTrack,
        "天窗打开": value.sunroofOpen - 0,
        "童锁": value.childLock,
        "香氛强度": value.fragranceIntensity - 0,
        "计时器": value.timer - 0,
        "计时器状态": value.timer === "0" ? "关闭" : "运行中",
        "氛围灯": "关闭",
        "氛围灯颜色": value.ambientLight,
        "氛围灯亮度": 0
      }
    },
    changeZoomVal(value) {
      this.zoomVal = value 
    }
  }
})